home *** CD-ROM | disk | FTP | other *** search
- Program Name: ANTIBOMB.PRG
- Written By: Greg Baker
- Distributed by: Inland Specialty Products
-
-
- If you're tired of the cherry bombs or mushroom clouds
-
- displayed when a program crashes then you'll find this utility
-
- essential. It replaces the bombs with a user friendly alert box
-
- that identifies the error in English. It runs from the Desktop or
-
- from the AUTO folder. For all STs, all resolutions.
-
-
- A couple of weeks ago, I was testing a new program which I had
-
- written when something terrible happened. Those strange little
-
- cherry bombs appeared on the screen. What did they mean? After
-
- thumbing through my pile of ST books (I know the error descriptions
-
- are in them somewhere) I discovered I had a BUS ERROR. Why couldn't
-
- the system tell me that!
-
-
- Now I don't have to scramble for my books anymore; I've made
-
- my ST more intelligent. Instead of those little bombs I now get an
-
- Alert box which displays the error message in text format -- and so
-
- can you!
-
-
- Changing the Exceptions
-
- The instructions for using ANTIBOMB are very simple. The
-
- program is named ANTIBOMB.PRG on the accompanying disk. You may run
-
- it from the GEM Desktop or place it in the AUTO folder on your boot
-
- disk if you'd like it to be installed automatically when you turn
-
- on your ST. It's very short, so it doesn't take much memory from
-
- the system.
-
-
- So what does it do? It replaces the bombs with an Alert box
-
- that describes what the error is. It also gives you the
-
- opportunity, depending on the exception type to either continue
-
- with the program, terminate the program, or reboot(warm or cold)
-
- the system.
-
-
- So What is an Exception?
-
- An exception allows the 68000 to interupt what it is doing, go
-
- do something else, then go back to the task that was originally
-
- interupted. ANTIBOMB.PRG traps the following exceptions:
-
-
- Bus Error: An exception is generated whenever the
- BERR signal is asserted by external logic.
-
- Address Error: An attempt to access either word data,
- long word data, or an instruction at an odd
- address.
-
- Illegal Instruction: System tried to process an invalid
- opcode.
-
- Divide by Zero: System tried to divide a number by zero.
-
- CHK instruction: Does a boundary check to see if the
- contents of a data register are in the
- range from zero to an upper limit.
- If less then zero or greater than the
- upper limit this exception will be
- generated.
-
- TRAPV Instruction: If the overflow bit (bit 1) in the status
- register is set when this instruction is
- executed then an exception is generated.
-
- Privileged Instruction: An exception will be generated if the
- following instructions are executed in
- USER mode; STOP, RESET, RTE, MOVE to SR,
- AND immediate to SR, EOR immediate to SR,
- OR immediate to SR, and MOVE USP.
-
- Trace Trap: If the T-bit (bit 15) in the status register is set
- then an exception will be generated after each
- instruction. This is useful for program debugging.
-
-
- How it Works
-
- ANTIBOMB is a terminate and stay resident program written in
-
- Mark Williams C. It redirects the above exception vectors to itself
-
- and then waits for an exception to occur. When an exception occurs
-
- an Alert box is displayed notifying the user which exception has
-
- occured and gives the opportunity to either continue with the
-
- program, terminate the program, or reboot(warm or cold) the system.
-
-
- PROGRAM FLOW
-
- First, appl_init is called to register the program with the
-
- AES. This allows the Alert box to be displayed when an exception
-
- occurs. Then, Setexc is used to redirect the exception vectors
-
- so they point to specific routines within ANTIBOMB. For example,
-
- the line Setexc(BUS_ERROR,bus_error) sets the exception vector so
-
- that whenever a Bus Error occurs the bus_error routine will be
-
- executed.
-
- Since all the exception routines function in the same way only
-
- the bus_error routine will be discussed in detail. The bus_error
-
- routine first calls setexc routine so that the registers are saved
-
- and the stack pointer is re-adjusted to allow processing of the
-
- retexc routine. This allows the CONTINUE button in the alert box to
-
- pass control back to the interupted program or to terminate the
-
- program depending on the exception type. The display routine will
-
- take the message passed from bus_error and display it in the Alert
-
- box. This routine also passes the error_code which is used to
-
- determine whether the program should continue or terminate. The
-
- User is then given the opportunity to either return and continue
-
- with the program, terminate the program, or reboot(warm or cold)
-
- the ST.
-
- If continue is selected then ANTIBOMB will check the
-
- error_code to see if the program should be continued or terminated.
-
- If the error_code says continue then ANTIBOMB will return to the
-
- interupted program and continues execution. This return is executed
-
- by the retexc routine in module setexc.s. Retexc will retore the
-
- saved registers then return to the interupted program via the RTE
-
- instruction. If the error_code says to terminate then ANTIBOMB will
-
- use the PTERM() function to abort the program.
-
-
- If a warm reboot is selected then ANTIBOMB jumps to the reset
-
- address contained in memory location 0x004. This memory location is
-
- also used when the reset button is pressed. If a cold reboot is
-
- selected then magic number located at 0x420 which tells the
-
- operating system that a coldstart was sucessfully done is cleared.
-
- ANTIBOMB then jumps to the start of the operating system (0x5000)
-
- and a cold restart is performed.
-
-
-
- So Who gets Terminated?
-
- As stated previously when some exceptions occur the program
-
- will be aborted when the continue but is pressed. The following
-
- table identifies each of the exceptions and whether they continue
-
- or terminate.
-
- Exception Type ERROR_CODE=
- Buss Error Terminate
- Address Error Terminate
- Illegal Instruction Continue
- Divide by Zero Continue
- Check Instruction Continue
- TrapV Instruction Continue
- Privilege Instruction Continue
- Trace Trap Continue
-
-
-
-
- Let's try it
-
- First execute the ANTIBOMB.PRG program from the Desktop (or
-
- AUTO folder). Now, run the EXCEPTION.PRG program. First you will be
-
- notified of a DIVIDE BY ZERO error. Press CONTINUE. The Desktop
-
- will be redisplayed. Now, run the EXCEPTION.PRG program again. This
-
- time press REBOOT. The ST will reboot.
-
-
-
- Want the Source???
-
- Mark Williams C was used to develop this utility. The source is
-
- available for $5.00 from:
-
- Inland Specialty Products
- N. 4112 Simpson Rd.
- Otis Orchards, Wa. 99027
-